﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for NguoiDungDAO
/// </summary>
public class NguoiDungDAO:AbstractDAO
{
	public NguoiDungDAO(String strPath)
        : base(strPath)
    {

    }
    ~NguoiDungDAO()
    {
        base.Dispose();
    }

    public DataSet SelectNguoiDung(Guid id)
    {
        DataSet ds;
        try
        {
            ds = new DataSet();
            base.sql = "usp_SelectNguoiDung";
            base.InitializeCommand();

            base.AddParameter("@id",
            SqlDbType.UniqueIdentifier, 100, id);

            base.FillDataSet(ref ds, "SelectNguoiDung");
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
        finally
        {
            base.CleanUpObject();
        }
    }

    public Boolean UpdateNguoiDung(NguoiDungDTO nd)
    {
        try
        {
            base.sql = "usp_UpdateNguoiDung";
            base.InitializeCommand();

            base.AddParameter("@id",
            SqlDbType.UniqueIdentifier, 200, nd.Id);

            base.AddParameter("@Ten",
            SqlDbType.NVarChar, 100, nd.HoTen);

            base.AddParameter("@DiaChi",
            SqlDbType.NVarChar, 100, nd.DiaChi);

            base.AddParameter("@GioiTinh",
            SqlDbType.Int, 10, nd.GioiTinh);

            base.AddParameter("@NgaySinh",
            SqlDbType.DateTime, 100, nd.NgaySinh);

            base.AddParameter("@NgheNghiep",
            SqlDbType.NVarChar, 100, nd.NgheNghiep);

            base.AddParameter("@DienThoai",
            SqlDbType.NVarChar, 100, nd.DienThoai);

            return ExecuteStoredProcedure();
        }
        catch (System.Exception ExceptionErr)
        {
            throw new Exception(ExceptionErr.Message, ExceptionErr.InnerException);

        }
    }
    public Boolean InsertNguoiDung(Guid id)
    {
        try
        {
            base.sql = "usp_InsertNguoiDung";
            base.InitializeCommand();

            base.AddParameter("@id",
            SqlDbType.UniqueIdentifier, 200, id);

            return ExecuteStoredProcedure();
        }
        catch (System.Exception ExceptionErr)
        {
            throw new Exception(ExceptionErr.Message, ExceptionErr.InnerException);

        }
    }
}
